﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Deflection
{
    /// <summary>
    /// A Sub Wave is a collection of enemies following a path on the screen
    /// </summary>
    class SubWave
    {
        public int OrderNumber { get; set; }
        public Path Path { get; set; }
        public Vector2 SpawnPosition { get; set; }
        public Vector2 PathPosition { get; set; }
        public float SpawnInterval  { get; set; }
        public int NumberOfEnemies  { get; set; }
        public Enemy.EnemyType EnemyType  { get; set; }

        public bool Active  { get; set; }
        public bool Spawning  { get; set; }

        public int EnemyCount { get; set; }

        public SubWave(int orderNumber, Path path, Vector2 spawnPosition, /*Vector2 pathPosition,*/ float spawnInterval, int numberOfEnemies, Enemy.EnemyType enemyType)
        {
            OrderNumber = orderNumber;
            Path = path;
            SpawnInterval = spawnInterval;
            NumberOfEnemies = numberOfEnemies;
            EnemyType = enemyType;
            Spawning = true;

            // zomg a path following a path !?!?

        }

        public void Update(GameTime gameTime)
        {
            if(Spawning)
            {
                if (gameTime.TotalGameTime.Milliseconds % SpawnInterval == 0)
                {
                    if (EnemyCount < NumberOfEnemies)
                    {
                        // Spawn enemies
                        EnemyFactory.Instance().CreateEnemy(SpawnPosition, Path, EnemyType);
                    }
                    else
                    {
                        Spawning = false;
                    }
                }
            }
            
        }

        public void Draw(GameTime gameTime)
        {

        }

    }
}
